package com.tbvtc.agriculturalcreditchainserver2025.mapper;

import com.tbvtc.agriculturalcreditchainserver2025.vo.AuthUser;
import com.tbvtc.agriculturalcreditchainserver2025.vo.LoginDto;
import com.tbvtc.agriculturalcreditchainserver2025.vo.UserVo;
import com.tbvtc.agriculturalcreditchainserver2025.vo.farmerVo.loginVo;
import org.apache.ibatis.annotations.*;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;
import java.util.List;

@Mapper
public interface AuthMapper {
    @Insert("insert into user (role_id,username,phone,password,address,create_time,update_time,is_audit,user_image) values" +
            " (#{roleId},#{username},#{phone},#{password},#{Address},#{createTime},#{updateTime},#{isAudit},#{userImage});")
    void register(AuthUser user);
   @Select("select phone from user")
    List<String> selectPhone();
     @Select("select * from user where phone=#{phone} and password=#{password}")
     loginVo Login(LoginDto loginDto);
    @Insert("insert into qualification_certificates (image_url,user_id) values (#{hash},#{id});")
    void addUpload(String hash,Integer id);
    @Delete("delete from qualification_certificates where id=#{id};")
    void rmUpload(Integer id);
      @Update("update user set password=#{newPassword} where phone=#{phone};")
    void findPassword(String phone, String newPassword);
    @Insert("INSERT into crop_image (crop_id,image_hash) values (#{id},#{hash})")
    void addUploadFood(String hash, Integer id);
    @Delete("delete from user where phone=#{phone};")
    void deleteUser(String phone);
  @Select("select user.is_audit from user where phone=#{phone}")
    Long getAudit(String phone);
    @Select("select user.is_disable from user where phone=#{phone}")
    Long getDisable( String phone);
}
